import React, { Component } from 'react'

export default class FormSim extends Component {

  state={
    user:"",
    pass:'',
    repass:''

  }

  save=e=>{
    let name=e.target.name
    this.setState({
      [name]:e.target.value
    })
  }


  render() {
    return (
      <div>
        <form action="">
          <hr />
          用户名：<input type="text" name="" value={this.state.user} onChange={this.save} />
          <br />
          密码：<input type="text" name="" value={this.state.pass} onChange={this.save} />
          <br />
          确认密码：<input type="text" name="" value={this.state.repass} onChange={this.save} />
          <button onClick={this.login}>登录</button>
          <button type="button" onClick={this.reset}>重置</button>
        </form>
      </div>
    )
  }

  login=(e)=>{
    e.preventDefault()
    console.log(`用户名: ${this.state.user} 密码: ${this.state.pass}`)
  }
  reset=()=>{
    this.setState({
      user:'',
      pass:''
    })
  }

}
